<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h1>{{ count }}</h1>

      <button @click="fn1">count ++</button>
    </div>

    <script src="../lib/vue.js"></script>
    <script>
      const vm = new Vue({
        el: "#app",
        // 状态数据、响应式数据
        data: {
          count: 10,
        },
        methods: {
          fn1() {
            this.count++;
            // 获取到真实的DOM数据, 需要使用 nextTick 传递一个回调函数，
            // 该回调函数的执行时机，是在这一轮数据更新完且真实DOM也更新完成之后，触发。

            this.$nextTick(() => {
              console.log(document.querySelector("h1").innerHTML);
            });
          },
        },
        async beforeMount() {},
      });
    </script>
  </body>
</html>
